﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace GetMusic
{
    public class GetMusic
        {
            private string[] direc, winList;
            private string[] filTyper = { ".mp3" };
            public GetMusic(string[] path)
            {
                //string[] path = { "P:\\Musikk\\" };
          

                int tot = 0;

                foreach (string f in path)
                {
                    string[] dir = Directory.GetDirectories(f);
                    foreach (string g in dir)
                        tot++;
                }

                direc = new string[tot];
                foreach (string f in path)
                {
                    string[] dir = Directory.GetDirectories(f);
                    dir.CopyTo(direc, getLastNull(direc));
                }
                winList = direc;
            }


            public string[] getDir()
            {
                return direc;
            }
            public string getName(int index)
            {
                return winList[index];
            }
            private int getLastNull(string[] temp)
            {
                for (int i = 0; i < temp.Length; i++)
                    if (temp[i] == null)
                        return i;
                return -1;
            }
            public string[] getSubDir(string sub)
            {
                Console.WriteLine(sub);
                for (int i = 0; i < this.filTyper.Length; i++)
                    if (sub.EndsWith(this.filTyper[i]))
                        return null;
                return Directory.GetDirectories(sub);
            }
            public void setWinList(string[] winList)
            {
                this.winList = winList;
            }

            public string[] getSanger(string path){
                return Directory.GetFiles(path, "*.*");
            }
    }
}